<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
	<link href="js/select2/select2.min.css" type="text/css" rel="stylesheet" />
	<script src="js/select2/select2.min.js"></script>
	<script type="text/javascript">
		$(document).ready(function() {
			var s1=$("#roomTypeId").select2();
			initSelectData();
			s1.val("起居室").trigger("change");
		});
		function initSelectData(){
			var html = "";
			var arr = ["起居室","餐厅","厨房","储物间","卫生间","房间","平台","阳台"];
			for(var i = 0;i<arr.length;i++){
				html = "<option value=\""+arr[i]+"\">"+arr[i]+"</option>";
				$("#roomTypeId").append(html);
			}
		}
	</script>
	<div class="main">
 		<div style="height: 34px;">
			房屋类型：<select  class="js-example-basic-single" name="roomTypeId" id="roomTypeId" style="width:135px;">
				
			</select>
			房间性质：<span id="roomPurpose"></span>
			&nbsp; <a class='btn btn-success radius'  onClick=doSearch()  >查 询</a>
			&nbsp; <a id="room_btn_add"  class='btn btn-primary radius'  onClick='doAddVacant()'>空置</a> 
			&nbsp; <a id="room_btn_add"  class='btn btn-primary radius' onClick='openAddIndoor(this)' >在用</a> 
		</div>
		<div class="mt-20" style="margin-top:10px;">
			<table id="searchTable_3" width="100%">
				<tr>
					<th w_index="no" width="5%;" w_align="center">序号</th>
					<th w_index="roomNum" width="5%;" w_align="center">房号</th>
					<th w_index="customerName" width="10%;" w_align="center">客户名称</th>
					<th w_index="roomPurpose" width="5%" w_align="center">房间性质</th>
					<th w_index="roomType" width="5%" w_align="center">房间类型</th>
					<th w_index="roomStatus" width="5%" w_align="center">使用状态</th>
					<th w_index="datails" width="10%;" w_render="Data_3">操作</th>
					<th w_hidden="true" w_index="id" >id</th>
				</tr>
			</table>
			<script type="text/javascript">
				var gridObj_3;
				$(function () {
					roomPurpose();
					gridObj_3 = $.fn.bsgrid.init('searchTable_3', {
						url: "project/decorateManager/getIndoorManagerJsonData",
						autoLoad: true,
						pageSizeSelect: true, 
						multiSort: true ,
						displayBlankRows: false ,
						pagingLittleToolbar: true,
						stripeRows: true,
						rowHoverColor: true,
						pageSize: 15,
						curPage:1
					});
				});
				function Data_3(record, rowIndex, colIndex, options) {
					var html="";
					var id = gridObj_3.getRecordIndexValue(record, 'id');
					var elementids2 = $("#sys_permissionids").val();
					
					var sys_user_id=$("#sys_user_id").val();
					var addUserid = gridObj.getRecordIndexValue(record, 'addUserid');
					var sys_userid = $("#sys_userid").val();
					html = " &nbsp; &nbsp; <a  href=javascript:look_3('"+id+"'); >查看</a>";
					if(elementids2.indexOf("table_with_a_record-data-edit")!=-1 ||addUserid.indexOf(sys_userid)!=-1 ||addUserid.indexOf(sys_user_id)!=-1){
					html+= " &nbsp; &nbsp; <a href=javascript:edit_3('"+id+"',this); >编辑</a>";
					}else{
						html += "&nbsp; &nbsp; <a style='cursor:text'>--</a>";
					}	
					if(elementids2.indexOf("table_with_a_record-data-del")!=-1 ||addUserid.indexOf(sys_userid)!=-1 ||addUserid.indexOf(sys_user_id)!=-1){
					html+=" &nbsp; &nbsp; <a   href=javascript:doDel_3('"+id+"'); >删除</a>";
					}else{
						html += "&nbsp; &nbsp; <a style='cursor:text'>--</a>";
					}
					return html;
				}
			//新增页面
			function openAddIndoor(obj) {
				var roomInfoId =　"${roomInfo.id}";
				var sortNum = $("#sortNum").val();
				var url="project/decorateManager/toAddIndoor/"+roomInfoId+"/"+sortNum;
				$(obj).attr('data-title',"添加室内管理");
				$(obj).attr('_href',url);
				Hui_admin_tab(obj);

			}
			
			function edit_3(id,obj) {
				var url="project/decorateManager/toEditIndoor/"+id;
				$(obj).attr('data-title',"修改室内管理");
				$(obj).attr('_href',url);
				Hui_admin_tab(obj);

			}
			/* function doAddVacant() {
				var url="project/decorateManager/toAddVacant";
				openTitleLayer("新增室内管理",url,800,400);
			} */
			function doAddVacant(){
				var roomInfoId =　"${roomInfo.id}";
				//var customerId=$("#customerId").val();
				var roomStatus="0";//空置
				var roomType=$("#roomTypeId").val();
				var roomPurpose=$("#sortNum").val();
				var url="project/decorateManager/addIndoor";
				$.ajax({
				    type:"post",
				    async:false,
				    url:url,
			        dataType:"json",
			        data:{
			        	roomId:roomInfoId,
			        	//customerId:customerId,
			        	roomStatus:roomStatus,
			        	roomType:roomType,
			        	roomPurpose:roomPurpose
			        },
				    success:function(responseText){
				        if(responseText.success){
				        	gridObj_3.refreshPage(); 
				        	layer.msg('保存成功！');
				        	//closeIframe();
		    			}else{
		    				alert(responseText.msg, {icon: 7});
		    			}
				    }
		   		});
			}
			
			function doDel_3(id) {
				var url="project/decorateManager/toDelIndoor";
				layer.confirm("确定删除吗？",{icon:3},function(i){
					jQuery.ajax({
					    type:"post",
						async:false,
						url:url,
						data:{id:id},
						success:function(data){
							if(data.success){
								gridObj_3.refreshPage(); 
							    layer.msg('删除成功！');
							 }else{
							    layer.alert(data.msg,{icon:7});
							 }
						}
					})
				})
			}
			
			function roomPurpose(){
				var sortNum = "${roomInfo.sortNum}";
				if(sortNum=="0"){
					$("#roomPurpose").text("写字楼");
				}else if(sortNum=="1"){
					$("#roomPurpose").text("商铺");
				}else if(sortNum=="2"){
					$("#roomPurpose").text("住宅");
				}
				$("#sortNum").val(sortNum);
			}
	</script>
	<input type="hidden" id="sortNum" name="sortNum" value=""/>
		</div>
 </div>

